package com.btsk.dao.hibernate;

import java.util.List;

import com.btsk.dao.CustomerSoftwareControlDao;
import com.btsk.model.CustomerSoftwareControl;
import com.btsk.model.NewGpsInfo;
import com.btsk.service.CustomerSoftwareControlManager;
@SuppressWarnings("unchecked")
public class CustomerSoftwareControlDaoHibernate extends
		GenericDaoHibernate<CustomerSoftwareControl, Long> implements
		CustomerSoftwareControlDao {

	public CustomerSoftwareControlDaoHibernate() {
		super(CustomerSoftwareControl.class);
	}
	
	@Override
	public CustomerSoftwareControl findCustomerSoftwareControlByCode(String code) {
		List<CustomerSoftwareControl> list = getHibernateTemplate().find(
				"from CustomerSoftwareControl o where o.code = ?",
				new Object[] { code });
			
		if (list.size() > 0){
			return list.get(0);
		}else{
			return null;
		}
	}


	@Override
	public CustomerSoftwareControl findCustomerSoftwareControlByCodeAndIp(String code, String ip) {
		List<CustomerSoftwareControl> list = getHibernateTemplate().find(
				"from CustomerSoftwareControl o where o.code = ? and o.ip = ?",
				new Object[] { code, ip });
		if (list.size() > 0){
			return list.get(0);
		}else{
			return null;
		}
	}
}
